from pydantic import BaseModel, Field
from typing import Optional, List
from datetime import datetime


class RoleResponse(BaseModel):
    id: Optional[int] = Field(None, description="角色ID")
    name: str = Field(..., description="角色名称")
    desc: Optional[str] = Field(None, description="角色描述")
    status: Optional[bool] = Field(True, description="状态：True启用，False禁用")
    create_time: Optional[datetime] = Field(None, description="创建时间")
    update_time: Optional[datetime] = Field(None, description="更新时间")

    class Config:
        from_attributes = True


class RoleListResponse(BaseModel):
    total: int = Field(..., description="总数量")
    items: List[RoleResponse] = Field(..., description="角色列表")
    page: int = Field(..., description="页码")
    size: int = Field(..., description="每页数量")
    pages: int = Field(..., description="总页数")


class RolePermissionsResponse(BaseModel):
    role_id: int = Field(..., description="角色ID")
    permission_ids: List[int] = Field(default_factory=list, description="权限ID列表")